/**
 * @Author 天下无敌
 * @Date 移除系统
 * @AIDE AIDE+ 
 */
package com.ecs.core.system;
import com.artemis.annotations.All;
import com.artemis.ComponentMapper;
//import com.ecs.core.debug.Debug;
import com.artemis.BaseEntitySystem;
import com.artemis.utils.IntBag;
import com.ecs.core.components.PendingDelete;

@All({PendingDelete.class})
public class PendingDeleteSystem extends BaseEntitySystem
{

	public static final String TAG = "PendingDeleteSystem";
	private ComponentMapper<PendingDelete> pendingDeletes;

	
	protected void process(int eid)
	{
		if(!world.getEntity(eid).isActive()) return;
		PendingDelete pd = pendingDeletes.get(eid);
		if(pd.delay > 0){
			pd.delay -= world.getDelta();
		}else{
			world.delete(eid);
			//Debug.log(TAG,String.format("deleteEntity id : %d", eid));
		}
	}

	@Override
	protected void processSystem()
	{
		IntBag ids = getEntityIds();
		for(int i = 0;i < ids.size();i++){
			process(ids.get(i));
		}
	}
	
}
